import okhttp3.*;

import java.io.IOException;
import java.net.MalformedURLException;
import java.net.URL;
import java.util.concurrent.TimeUnit;

/**
 * @ClassName L6
 * @Description 第6题
 * @Author Jingxiao.Ye
 * @Date 2021/11/14 下午10:53
 * @Version V1.0
 * @Since JDK 11
 */
public class L6 {

    public static void main(String[] args) {
        //http://localhost:8801
        OkHttpClient okHttpClient = new OkHttpClient().newBuilder()
                .connectionPool(new ConnectionPool())
                .readTimeout(10,TimeUnit.SECONDS)
                .writeTimeout(10,TimeUnit.SECONDS)
                .build();
        Request request = new Request.Builder().url("http://localhost:8801")
                .build();
        Call call = okHttpClient.newCall(request);
        Response execute = null;
        try {
            execute = call.execute();
            ResponseBody body = execute.body();
            System.out.println(body.string());
        } catch (IOException e) {
            e.printStackTrace();
        }finally {
            if (execute != null) {
                execute.close();
            }
        }
    }
}
